package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.system.domain.DanmoSecurityLogs;
import com.muyu.system.service.IDanmoSecurityLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 安全日志
Controller
 *
 * @author yangle
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/securityLogs")
public class DanmoSecurityLogsController extends BaseController
{
    @Autowired
    private IDanmoSecurityLogsService danmoSecurityLogsService;

    /**
     * 查询安全日志
     * 列表
     */
//    @RequiresPermissions("system:danmoSecurityLogs:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoSecurityLogs>> list(DanmoSecurityLogs danmoSecurityLogs)
    {
        startPage();
        List<DanmoSecurityLogs> list = danmoSecurityLogsService.selectDanmoSecurityLogsList(danmoSecurityLogs);
        return getDataTable(list);
    }

    /**
     * 导出安全日志列表
     */
//    @RequiresPermissions("system:danmoSecurityLogs:export")
    @Log(title = "安全日志 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoSecurityLogs danmoSecurityLogs)
    {
        List<DanmoSecurityLogs> list = danmoSecurityLogsService.selectDanmoSecurityLogsList(danmoSecurityLogs);
        ExcelUtil<DanmoSecurityLogs> util = new ExcelUtil<DanmoSecurityLogs>(DanmoSecurityLogs.class);
        util.exportExcel(response, list, "安全日志 数据");
    }

    /**
     * 获取安全日志详细信息
     */
//    @RequiresPermissions("system:danmoSecurityLogs:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoSecurityLogsService.selectDanmoSecurityLogsById(id));
    }

    /**
     * 新增安全日志

     */
//    @RequiresPermissions("system:danmoSecurityLogs:add")
    @Log(title = "安全日志 ", businessType = BusinessType.INSERT)
    @PostMapping("/rankingOfPopularity")
    public Result add(@RequestBody DanmoSecurityLogs danmoSecurityLogs)
    {
        return danmoSecurityLogsService.insertDanmoSecurityLogs(danmoSecurityLogs);
    }

    /**
     * 修改安全日志

     */
//    @RequiresPermissions("system:danmoSecurityLogs:edit")
    @Log(title = "安全日志 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoSecurityLogs danmoSecurityLogs)
    {
        return danmoSecurityLogsService.updateDanmoSecurityLogs(danmoSecurityLogs);
    }

    /**
     * 删除安全日志

     */
//    @RequiresPermissions("system:danmoSecurityLogs:remove")
    @Log(title = "安全日志 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return danmoSecurityLogsService.deleteDanmoSecurityLogsByIds(ids);
    }
}
